package com.ahead.customvideo;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Environment;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.Toast;

import java.io.File;

public class MainActivity extends AppCompatActivity implements SurfaceHolder.Callback {

    SurfaceView sv_video;
    String filePath;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



        sv_video = findViewById(R.id.sv_video);

        sv_video.getHolder().addCallback(this);

    }


    @Override
    public void surfaceCreated(@NonNull SurfaceHolder surfaceHolder) {
         filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath();
         filePath = filePath+"/a.mp4";
         if(!new File(filePath).exists()){
             Toast.makeText(this, "文件不存在", Toast.LENGTH_SHORT).show();
         }
         //todo 初始化 MediaExtrator MediaCodec AudioTrack


    }

    @Override
    public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int i, int i1, int i2) {

    }

    @Override
    public void surfaceDestroyed(@NonNull SurfaceHolder surfaceHolder) {

    }
}